package com.valeandre.euroro.model;

import java.util.ArrayList;
import java.util.List;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

@Root(name="currency")
public class Currency {
	
	public static final String DOLLAR = "usd";
	public static final String EURO = "eur";

	@Attribute(required=true)
	private String access;
	
	@ElementList (inline = true, required = false)
	private List<Price> prices= new ArrayList<Price>();

	public String getAccess() {
		return access;
	}

	public void setAccess(String access) {
		this.access = access;
	}

	public List<Price> getPrices() {
		return prices;
	}

	public void setPrices(List<Price> prices) {
		this.prices = prices;
	}
	
	public Price getPrice(String price) {
		Price ret = null;
		if (prices != null && prices.size() > 0) {
			for (Price p : prices) {
				if(p.getAccess().equals(price)) {
					ret = p;
				}
			}
		}
		return ret;
	}
	
}
